<%--
  Created by IntelliJ IDEA.
  User: lujw
  Date: 2017/6/15
  Time: 8:56
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="/common/validate.jsp"%>
<%@ include file="/common/hospital_notice.jsp"%>
<%!
    /**
     * 查看评论列表(分页)
     * @param input
     * @return
     */
    public Message commentList(Input input) {
        Integer page = 1; // 页码
        Integer itemCount = 20; // 每一页条目
        Integer hospital = input.getInt("hospital", -1);
        //通知id
        Integer noticeId = input.getInt("notice_id", -1);
        //评论id
        Integer commentId = input.getInt("comment_id", -1);
        //评论时间
        String commentTime = input.getDesc("comment_time", "");
        String selectContent = "new map(u.id as user_id, u.name as name, u.avatar as avatar, u.gender as gender, c.content as content, c.time as time, c.id as id, c.atId as at_id)";
        Where where = new Where("c.status=", ConstantUtil.STATUS_ENABLE).and("c.noticeId=", noticeId).and("c.hospital=", hospital).and("u.hospital=", hospital).and("u.status=", ConstantUtil.STATUS_ENABLE).and("c.userId=u.id");
        if (!"".equals(commentTime) && commentId != -1) {
            where.and("c.time < '"+commentTime + "' or (c.time = '" + commentTime + "' and c.id < " + commentId + ")");
        }
        List<Map> list = QBuilder.db("basedb").select(selectContent).from("HospitalUser u, HospitalNoticeComment c").where(where).order("c.time desc, ", "c.id desc").page(itemCount, page).query().getResultObj();
        completeUserDept(list, hospital);
        Message msg = new Message();
        msg.put("data", list);
        return msg;
    }
%>
<%
    Tools.encryptPrint(out, commentList(input));
%>
